import request from '@/axios'
import type { RealmForm, RealmTableView } from './types'

export const query = (data: PaginationRequest): Promise<PaginationResponse<RealmTableView>> => {
    return request.post({
        url: '/realm/query',
        data
    })
}

export const get = (id: string): Promise<RealmForm> => {
    return request.get({
        url: `/realm/${id}`
    })
}

export const add = (data: RealmForm): Promise<ApiResult> => {
    return request.post({
        url: '/realm',
        data
    })
}

export const edit = (id: string, data: RealmForm): Promise<ApiResult> => {
    return request.put({
        url: `/realm/${id}`,
        data
    })
}

export const remove = (id: string): Promise<ApiResult> => {
    return request.delete({
        url: `/realm/${id}`
    })
}

export const options = (): Promise<SelectOption[]> => {
    return request.get({
        url: '/realm/options'
    })
}